home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 18 / 018.d81 / comal tutor#5 (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  27KB  |  681 lines

  1. 5 ifpeek(51200)<>76orpeek(52016)<>32then7
  2. 6 ifpeek(52080)=173andpeek(52176)=169then8
  3. 7 load"routines v4",8,1
  4. 8 pokev+33,1:q$=chr$(34)
  5. 10 r=53265:c=128:v=53248:s=v+1024:li=52016:wi=51200:cl=51203:su=51206:sd=51209
  6. 12 pokes+23,.:pokes+4,128:pokev+32,14
  7. 15 gosub1000:print"   [215]elcome to the fifth chapter of"
  8. 16 print"[204]oadstar's [195][207][205][193][204][160]0.14 [212]utorial.  [201]n
  9. 17 [153]"the previous chapter, we converted our
  10. 18 print"now-familiar [195]elsius program into a
  11. 19 [153]"asc(NULL)(NULL)lention, as well as learned about the
  12. 20 print"[201]mmediate [205]ode and other concepts.  [201]f
  13. 21 [153]"you are unsure of any of these, you
  14. 22 print"may wish to [211][212][207][208] this lesson now and
  15. 23 [153]"take a previous lesson or three before
  16. 24 print"returning here.":gosub1200
  17. 25 print"   [201]n this chapter, we will expand on
  18. 26 [153]"our knowledge of asc(NULL)(NULL)lentions, and also
  19. 27 print"introduce some other kinds of [208][210][207][199][210][193][205]-
  20. 28 [153]"(NULL)right$(NULL)chr$close(NULL)(NULL)(NULL)(NULL)len(NULL)(NULL)(NULL)val(NULL).  ascirst, let's (NULL)(NULL)atnstr$
  21. 29 print"our work of last installment:
  22. 30 [153]"   (NULL)(NULL)atnstr$ "q$"len.asc.lenval(NULL)(NULL)right$(NULL)(NULL)"q$"
  23. 34 gosub1160:x%=.:y%=14:gosub1110:print"9902 [194][217][212][197][211][160][198][210][197][197]."
  24. 35 gosub1300:x%=.:y%=16:a$="[204][207][193][196] "+q$+"[195].[198].[195][197][204][211][201][213][211]"+q$:gosub1600
  25. 36 ifethena$=mid$(a$,e):e=.:gosub1605:goto36
  26. 37 gosub1500:ifk$<>chr$(13)then37
  27. 38 s=5:gosub2000:gosub1035:gosub1150
  28. 39 print"[144][146][196]one!  [199]uess what we're gonna do next?":gosub1205
  29. 40 print"   [210]ight!  [217]ou're gonna [204][201][211][212] it:
  30. 45 [141]1160:[141]1300:x%[178].:y%[178]18:a$[178]"(NULL)right$(NULL)(NULL)":[141]1600                           
  31. 46 [139]e[167]a$[178][202](a$,e):e[178].:[141]1605:[137]46
  32. 47 [141]1500:[139]k$[179][177][199](13)[167]47
  33. 48 [153]:[153]"0010 asc(NULL)(NULL)lencloselenval(NULL)(NULL)right$(NULL)(NULL)(ascatn(NULL)val(NULL)left$valright$(NULL))":[153]"0020  (NULL)val(NULL)(NULL)(NULL)(NULL)close(ascatn(NULL)val(NULL)left$valright$(NULL)-32)*(5/9)
  34. 49 print"0030 [197][206][196][198][213][206][195][160][195][197][204][211][201][213][211]":gosub1150
  35. 50 print"[144]   [199]ood!  [201]t still seems to be there:
  36. 51 [153]"the asc(NULL)(NULL)len statement in line 10 which
  37. 52 print"names the [198][213][206][195]tion and specifies the
  38. 53 [153]"argument, the (NULL)val(NULL)(NULL)(NULL)(NULL) statement in line
  39. 54 print"20 which specifies how to compute the
  40. 55 [153]"value of the asc(NULL)(NULL)lention given the argu-
  41. 56 print"ment, and the [197][206][196][198][213][206][195] in line 30 which
  42. 57 [153]"marks the end of the asc(NULL)(NULL)lention.":[141]1205
  43. 60 [153]"   (NULL)ast issue, we mentioned that a
  44. 61 print"[198][213][206][195]tion must have [193][212][160][204][197][193][211][212][160][207][206][197][160][210][197][212][213][210][206]
  45. 62 [153]"statement.  (NULL)hen might a asc(NULL)(NULL)lention need
  46. 63 print"more than 1?  [193] [198][213][206][195]tion can't [210][197][212][213][210][206]
  47. 64 [153]"more than 1 value per call!  (NULL)ell, right$
  48. 65 print"will show you an example later, but
  49. 66 [153]"first, we'll need to experiment some
  50. 67 print"more with [201]mmediate mode, and learn a
  51. 68 [153]"new concept or 3.  (NULL)hen, we'll use
  52. 69 print"those concepts in a new [198][213][206][195]tion!":gosub1200
  53. 70 print"   [198]rom our experiments, you know that
  54. 71 [153]"the symbols '+', '-', '*' and '/' mean
  55. 72 print"addition, subtraction, multiplication
  56. 73 [153]"and division, respectively.  (NULL)uch sym-
  57. 74 print"bols used in an expression are called
  58. 75 [153]"(NULL)(NULL)val(NULL)atn(NULL)(NULL)(NULL)(NULL).  (NULL)he values they operate on
  59. 76 print"are called [207][208][197][210][193][206][196][211].  [215]hat they do
  60. 77 [153]"with the operands is called an (NULL)(NULL)val(NULL)atn-
  61. 78 print"[212][201][207][206].  [195]lear as mud, right?  [193]llow me
  62. 79 [153]"to use an example:":[141]1200
  63. 80 [153]"   chr$iven the expression '5/9', the (NULL)(NULL)-
  64. 81 print"[197][210][193][212][207][210] is '/', the [207][208][197][210][193][206][196]s are '5' &
  65. 82 [153]"'9', and the (NULL)(NULL)val(NULL)atn(NULL)right$(NULL)(NULL)closeis division.
  66. 83 print"   [200]ere is a more complex expression:
  67. 84 [153]"'(ascatn(NULL)val(NULL)left$valright$(NULL)-32)*(5/9)'.  right$t has 3 op-
  68. 85 print"erations:  '[198][193][210][197][206][200][197][201][212]-32', '5/9' & the
  69. 86 [153]"product of the results of those two.
  70. 87 print"[212]hus, the result of an operation can
  71. 88 [153]"be an operand of another operation!":[141]1200
  72. 90 [153]"   right$n the case '(ascatn(NULL)val(NULL)left$valright$(NULL)-32)*(5/9)',
  73. 91 print"the operator is '*', the operands are
  74. 92 [153]"the results of 'ascatn(NULL)val(NULL)left$valright$(NULL)-32' &close'5/9',
  75. 93 print"and the operation is multiplication.
  76. 94 [153]"(NULL)e already did '5/9', so that leaves
  77. 95 print"'[198][193][210][197][206][200][197][201][212]-32'.  [212]he operator is '-',
  78. 96 [153]"the operands are the value of the var-
  79. 97 print"iable '[198][193][210][197][206][200][197][201][212]' &[160]'32', and the op-
  80. 98 [153]"eration is subtraction.  (NULL)arentheses
  81. 99 print"separate operations.":gosub1200
  82. 100 print"   [193]re there any more operators be-
  83. 101 [153]"sides the four arithmetic ones?  (NULL)es,
  84. 102 print"there is '^', which means 'exponenti-
  85. 103 [153]"ation', or 'raising to a power'.  (NULL)ot
  86. 104 print"only that, but '+' and '-' can mean
  87. 105 [153]"other things besides addition and sub-
  88. 106 print"traction.  [201]f they have only one oper-
  89. 107 [153]"and (after the operator), they mean
  90. 108 print"'identity'[160](no change) and 'negation'
  91. 109 [153]"(change sign), respectively.":[141]1200
  92. 110 [153]"   '+' even has another meaning, which
  93. 111 print"we'll cover in a future installment.
  94. 112 [153]"   (NULL)et's experiment with a new class
  95. 113 print"of operators.  [212]ype this:
  96. 114 [153]"   (NULL)(NULL)right$(NULL)(NULL)close2=2
  97. 115 gosub1160:gosub1300:x%=.:y%=23:a$="[208][210][201][206][212] 2=2":gosub1600
  98. 116 ifethena$=mid$(a$,e):e=.:gosub1605:goto116
  99. 117 gosub1500:ifk$<>chr$(13)then117
  100. 118 print:print"1";:gosub1700:gosub1700:gosub1035:gosub1150:print"[145][144]
  101. 119 [153]"   (NULL)ay (NULL)left$atn(NULL)!?  (NULL)et's try another. . .":[141]1205
  102. 120 [153]"   (NULL)ype:  (NULL)(NULL)right$(NULL)(NULL)close2=3
  103. 125 gosub1160:gosub1300:x%=.:y%=24:a$="[208][210][201][206][212] 2=3":gosub1600
  104. 126 ifethena$=mid$(a$,e):e=.:gosub1605:goto126
  105. 127 gosub1500:ifk$<>chr$(13)then127
  106. 128 gosub1700:print"0";:gosub1700:gosub1700:gosub1035:gosub1150:print"[145][144]
  107. 130 [153]"left$mmm . . . '2=2' is 1, and '2=3' is 0.
  108. 131 print"[211]eems to be a pattern here.  [212]ype:
  109. 132 [153]"   (NULL)(NULL)right$(NULL)(NULL)close2<3
  110. 135 gosub1160:x%=.:y%=24:a$="[208][210][201][206][212] 2<3":gosub1600
  111. 136 ifethena$=mid$(a$,e):e=.:gosub1605:goto136
  112. 137 gosub1500:ifk$<>chr$(13)then137
  113. 138 gosub1700:print"1";:gosub1700:gosub1700:gosub1035:gosub1150:print"[145][144]
  114. 140 [153]"   right$nteresting!  ascrom (NULL)ath class, you
  115. 141 print"may remember that '=' means 'is equal
  116. 142 [153]"to', and '<' means 'is less than'!":[141]1205
  117. 145 [153]"   right$t seems that with an expression
  118. 146 print"which could only be [212][210][213][197] or [198][193][204][211][197], [195][207]-
  119. 147 [153]"(NULL)atn(NULL)closereturns '1' for (NULL)(NULL)(NULL)valcloseand '0' for
  120. 148 print"[198][193][204][211][197].  [207]perators such as '=' and '<',
  121. 149 [153]"which return the truth of relation-
  122. 150 print"ships (such as 'is equal to' or 'is
  123. 151 [153]"less than') between their operands,
  124. 152 print"are called [210][197][204][193][212][201][207][206][193][204][160][207][208][197][210][193][212][207][210][211].":gosub1200
  125. 155 print"   [200]ere are some of these [210][197][204][193][212][201][207][206][193][204]
  126. 156 [153]"(NULL)(NULL)val(NULL)atn(NULL)(NULL)(NULL)(NULL):
  127. 157 print"   '='  ([201]s [197]qual [212]o)
  128. 158 [153]"   '<'  (right$s (NULL)ess (NULL)han)
  129. 159 p